<template>
  <div class="exhibits-content" :style="{ width: props.info.width + 'rem', height: props.info.height + 'rem' }">
    <div
      class="decorate"
      :style="{
        'background-image': `url(${publicUrls + 'free/style6/exhibitionStandStyle4zs.webp'})`,
      }"
    ></div>
    <div
      @contextmenu.stop="emit('onContextMenuChild', $event, index)"
      v-for="(item, index) in props.info.showpieceList"
      :key="index"
      class="exhibits-item"
    >
      <div
        class="item-content"
        :style="{
          'background-image':
            index < props.info.showpieceList?.length - 1
              ? `url(${publicUrls + 'free/style6/exhibitionStandStyle4Bg.webp'})`
              : `url(${publicUrls + 'free/style6/exhibitionStandStyle4Bg2.webp'})`,
        }"
      >
        <div class="cover-box" @click="viewImg(item.moduleId, item.id)">
          <img class="cover" v-lazy="getLinkUrl(item.coverUrl, '?imageView2/3/w/600/format/webp')" alt="" />
          <img
            class="flower-btn"
            v-if="route.meta.loopType"
            v-lazy="publicUrls + 'free/style6/flower.webp'"
          />
        </div>
        <div class="items-title">
          <p>{{ item.name }}</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
export default defineComponent({
  name: 'free6Style4',
});
</script>

<script setup lang="ts">
import { publicUrls } from '@/utils/minxin';
import { DraggableContainer } from 'vue3-draggable-resizable';
// import FlotMenu from '@/components/flotMenu/OutlineMenu.vue';
import ContextMenu from '@imengyu/vue3-context-menu';
import { getDraggableNumber, getExhibitsHeightRest, getdisabledY } from '@/utils/getRemComputed';
import { ref, reactive, watch, nextTick, defineComponent } from 'vue';
import { exbitMenuShow, exbitListMenuShow } from '@/hooks/menuHooks';
import { useProjectStore } from '@/store';
import { getLinkUrl } from '@/utils/request/upload';
import { useRoute } from 'vue-router';

const emit = defineEmits([
  'emitChildItemDraggable',
  'emitChildItemDraggableStyle',
  'emitShowcaseDraggable',
  'emitShowcaseDraggableStyle',
  'onContextMenuChild',
]);
const store = useProjectStore();
const contextMenuTrigger = ref(); //列表盒子dom
const parentLock = ref(true);
const childShow = ref(true);
const draggableResizable = ref(); //父级拖拽盒子ref
const timer = ref();
const ImgVisible = ref(false);
const ImgUrl = ref('');
const route = useRoute();

const props = defineProps({
  width: {
    type: Number || String,
  },
  height: {
    type: Number || String,
  },
  indexs: {
    type: Number,
  },
  info: {
    type: Object,
  },
  childId: {
    type: Number,
  },
  AuxiliaryId: {
    type: Number,
  },
});

const viewImg = (moduleId: number, e?: number) => {
  store.exhibitsModuleId = moduleId;
  store.exhibitsShowpieceid = e;
  store.exhibitsInfoShow = true;
};

const handleMouseDown = (event) => {
  event.stopPropagation();
};
const preventDefaultDrag = (event) => {
  event.stopPropagation();
};
// watch(
//   () => props.info.width,
//   () => {
//     childShow.value = false;
//     nextTick(() => {
//       childShow.value = true;
//     });
//   },
//   { deep: true },
// );
// watch(
//   () => props.info.height,
//   () => {
//     childShow.value = false;
//     nextTick(() => {
//       childShow.value = true;
//     });
//   },
//   { deep: true },
// );

//
</script>

<style lang="less" scoped>
.exhibits-content {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  z-index: 999;
  padding: 0 !important;
}

.active {
  :deep(.flot-menu) {
    display: flex;
  }
}
:deep(.active) {
  z-index: 999;
}
:deep(.vdr-handle) {
  z-index: 66;
}
.exhibits-item {
  display: flex;
  align-items: flex-end;
  width: 270px;
  height: 640px;
  margin-top: 120px;
  &:last-child .item-content {
    padding-right: 41px;
    .cover-box {
      width: 167px;
    }
    .items-title {
      left: 48.5%;
    }
  }
  .item-content {
    width: 100%;
    height: 100%;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 61px;
    padding-right: 34px;
    -webkit-box-reflect: below 0 linear-gradient(transparent, rgba(0, 0, 0, 0.15));
    position: relative;
    .cover-box {
      width: 172.5px;
      height: 240px;
      position: relative;
      overflow: hidden;
      &:hover .cover {
        transform: scale(1.2);
      }
      .cover {
        width: 100%;
        height: 100%;
        object-fit: contain;
        border-radius: 4px;
        transition: all 0.5s ease;
      }
      .flower-btn {
        width: 40px;
        height: 40px;
        object-fit: cover;
        position: absolute;
        top: 40%;
        left: 50%;
        transform: translate(-50%, -40%);
        animation: flower 2s linear infinite;
        @keyframes flower {
          0% {
            opacity: 0;
          }
          40% {
            opacity: 100%;
          }
          80% {
            opacity: 100%;
          }
          100% {
            opacity: 0;
          }
        }
      }
    }
    .items-title {
      width: 14px;
      height: 170px;
      position: absolute;
      left: 50%;
      bottom: 70px;
      transform: translate(-50%, 0);
      display: flex;
      justify-content: center;
      align-items: center;
      overflow: hidden;

      p {
        max-height: 170px;
        color: #efede9;
        font-size: 14px;
        line-height: 14px;
        font-family: SourceHanSerifCN-Bold;
        writing-mode: tb-rl;
        letter-spacing: 8px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }
  }
}

.decorate {
  width: 275px;
  height: 370px;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  margin-right: 59px;
  -webkit-box-reflect: below 80% linear-gradient(transparent, rgba(0, 0, 0, 0.15));
}
</style>
